package com.jackstraw.jack_base.mq.rocketmq.bean;

import com.jackstraw.jack_base.mq.rocketmq.bean.enums.TransactionStateEnum;
import lombok.Data;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.support.RocketMQUtil;

import java.io.Serializable;

/**
 * 事务消息回查用实体类
 */
@Data
public class TrListenerEntity implements Serializable {

    private org.springframework.messaging.Message springMessage;
    private org.apache.rocketmq.common.message.Message rocketmqMessage;
    private Object arg;
    private MessageExt messageExt;

    private TransactionStateEnum transactionStateEnum;

    public TrListenerEntity setRocketmqMessage(org.apache.rocketmq.common.message.Message rocketmqMessage) {
        this.rocketmqMessage = rocketmqMessage;
        this.springMessage = RocketMQUtil.convertToSpringMessage(rocketmqMessage);
        return this;
    }

    public TrListenerEntity setMessageExt(MessageExt messageExt) {
        this.messageExt = messageExt;
        this.springMessage = RocketMQUtil.convertToSpringMessage(messageExt);
        return this;
    }
}
